package com.ck.controller.teacher;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.ck.domain.Student;
import com.ck.service.TeacherService;

public class ShowStudentListForBanjiController extends AbstractController {
	
	private TeacherService teacherService;

	public void setTeacherService(TeacherService teacherService) {
		this.teacherService = teacherService;
	}
	
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		Integer banjiID = Integer.parseInt(request.getParameter("banjiID"));
		
		String banji_name = teacherService.gainBanji(banjiID).getName();
		List<Student> studentList = teacherService.gainStudentByBanji(banjiID);
		
		Map model = new HashMap();
		model.put("banji_name", banji_name);
		model.put("studentList", studentList);
		
		return new ModelAndView("teacher/showStudentListForBanji", model);
	}

}
